package com.qding.park.manager.pojo.queue;

import com.alibaba.fastjson.JSONObject;

/**
 * @ClassName QueueMsg
 * @Description TODO(消息队列消息模式)
 * @author Administrator
 * @Date 2016年9月15日 上午9:30:04
 * @version 1.0.0
 */
public class QueueMsg<T> {
	
	private String id;
	
	/**
	 * @Field @eventType : TODO(队列消息类型)
	 */
	private int eventType;
	
	/**
	 * @Field @data : TODO(数据字段)
	 */
	private T data;
	
	/**
	 * 执行序列 号
	 */
	private int serail=0;
	
	/**
	 * 失败次数
	 */
	private int failNum =0;
	
	public static String serialize(int eventType,Object data){
		
		QueueMsg msg=new QueueMsg();
		msg.setEventType(eventType);
		msg.setData(data);
		return JSONObject.toJSONString(msg);
	}
	
	public static QueueMsg unSerialize(String text) {

		QueueMsg msg=JSONObject.parseObject(text, QueueMsg.class);
		return msg;
	}
	
	public int getEventType() {
		return eventType;
	}

	public void setEventType(int eventType) {
		this.eventType = eventType;
	}


	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	@Override
	public String toString() {
		return "QueueMsg [eventType=" + eventType + ", data=" + data + "]";
	}

	public int getSerail() {
		return serail;
	}

	public void setSerail(int serail) {
		this.serail = serail;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int getFailNum() {
		return failNum;
	}

	public void setFailNum(int failNum) {
		this.failNum = failNum;
	}

	
	
	
}
